home *** CD-ROM | disk | FTP | other *** search
- /* Kevo -- a prototype-based object-oriented language */
- /* (c) Antero Taivalsaari 1991-1993 */
- /* Some parts (c) Antero Taivalsaari 1986-1988 */
- /* context.h: Name space (context) structures and internals */
-
- /*------------------------------------------------------------------------*/
- /* Context structures */
-
- /*
- Contexts are name spaces (vocabularies) that refer to the properties
- of objects. Context is a mapping from a set of names (PAIRs) to OBJECTs.
- An individual pair is a mapping from a name to an object.
-
- Context is implemented as a bidirectional linked list of pairs. To one
- direction the linked list is hashed (multi-linked) to speed up the name
- lookup. To the other direction there is only a single link that tells the
- original definition order of the properties.
- */
-
- /* Number of threads in the multi-linked (hashed) dictionary structure.
- This can be any positive integer (default = 8).
- The more threads we have, the faster the lookup
- (but more memory is also required). */
- #define CONTEXTSIZE 8
-
- typedef struct contextStruct CONTEXT;
- typedef struct pairStruct PAIR;
-
- struct contextStruct {
- PAIR* lastPair[CONTEXTSIZE]; /* Array of pointers to latest pairs */
- PAIR* firstPair; /* Pointer to first pair */
- PAIR* latestPair; /* Pointer to latest definition */
- CONTEXT* nextContext; /* Next defined context in the system */
- LIST* cloneFamily; /* Contains all the OOP objects of this kind */
- LIST* parentFamilies; /* Contains "parent" clone families */
- LIST* childFamilies; /* Contains "child" clone families */
- };
-
- /*
- Keep 'ofa' as the first field of 'pairStruct'.
- This is important for efficiency.
- */
-
- struct pairStruct {
- OBJECT* ofa; /* Target of the identifier (object field address) */
- char* nfa; /* Identifier name (name field address) */
- PAIR* lfa; /* Pointer to the previous pair (link field address) */
- PAIR* sfa; /* Pointer to next pair (successor field address) */
- CONTEXT* cfa; /* Pointer to the context to which this pair belongs */
- int ffa; /* Flag field (flag field address) */
- };
-
- /* The following operations are "inlined" for speed */
-
- #define hash(id) ((int)(*id) % CONTEXTSIZE)
- #define getContext(object) ((CONTEXT*)(object)->mfa->pfa)
-
-
- CONTEXT* createContext();
- CONTEXT* copyContext();
- void deleteContext();
-
- int comparePairs();
- int compareContexts();
- int compareContextResemblance();
-
- int isContextObject();
- /* CONTEXT* getContext(); */
-
- PAIR* addPair();
- void unlinkPair();
- void renamePair();
- void hide();
- PAIR* copyPair();
- PAIR* addBeforePair();
-
- PAIR* findPairInThis();
- PAIR* findPairBackward();
-
- PAIR* findNameInThis();
- PAIR* findNameBackward();
- PAIR* findNameForward();
-
- PAIR* findTypeForward();
- PAIR* findPrimName();
-
-
- /* Object-oriented operations */
-
- PAIR* selfLookUp();
- PAIR* messageLookUp();
- PAIR* respondsTo();
-
- OBJECT** getREFslot();
- int getVARoffset();
- OBJECT** getVARslot();
-
- int countAllPairs();
- int countDataPairs();
- int countOperPairs();
-
- PAIR* findAllAsIndexed();
- PAIR* findDataAsIndexed();
- PAIR* findOperAsIndexed();
-
- void checkIntegrity();
-